package android.concisapp.fragments;

import java.util.ArrayList;

import android.concisapp.R;
import android.concisapp.parser.CalendarItem;
import android.concisapp.parser.ParserCalendarList;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView.FindListener;
import android.widget.CalendarView;

public class CalendarFragment extends Fragment {

	public static final String CALENDAR_URL = "https://www.google.com/calendar/feeds/2fs98kspp7n30prf8vvmbnh33c%40group.calendar.google.com/public/basic";
	public static final String EXTRA_MESSAGE = "EXTRA_MESSAGE";
	
	private CalendarView calendarView;

	public static final android.support.v4.app.Fragment newInstance(
			String message) {
		android.support.v4.app.Fragment f = (android.support.v4.app.Fragment) new CalendarFragment();
		Bundle bdl = new Bundle(1);
		bdl.putString(EXTRA_MESSAGE, message);
		f.setArguments(bdl);
		return f;
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View rootView = inflater.inflate(R.layout.calendario, container, false);
		calendarView = (CalendarView) rootView.findViewById(R.id.calendarView);
		new GetFeedTask().execute();
		return rootView;
	}

	private class GetFeedTask extends
			AsyncTask<String, Void, ArrayList<CalendarItem>> {

		@Override
		protected void onPreExecute() {
			// TODO Auto-generated method stub
			super.onPreExecute();
		}

		@Override
		protected ArrayList<CalendarItem> doInBackground(String... params) {
			ParserCalendarList p = new ParserCalendarList();
			return p.getArrayItem();
		}

		@Override
		protected void onPostExecute(ArrayList<CalendarItem> result) {
			Log.d("GETCALENDAR", "Finished!");
//			calendarView.
			
		}

	}

}
